<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateVOwnerRoutesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('v_owner_routes', function (Blueprint $table) {
            $table->increments('id');
            $table->uuid('owner_uuid')->comment('货主唯一标识');
            $table->string('src_province_code',32)->default('')->comment('出发地省份');
            $table->string('src_city_code',32)->default('')->comment('出发地城市');
            $table->string('src_district_code',32)->default('')->comment('出发地区域');
            $table->string('src_address',512)->default('')->comment('出发地详细地址');
            $table->string('src_location',64)->default('')->comment('出发地经纬度');
            $table->string('dst_province_code',32)->default('')->comment('目的地省份');
            $table->string('dst_city_code',32)->default('')->comment('目的地城市');
            $table->string('dst_district_code',32)->default('')->comment('目的地区域');
            $table->string('dst_address',512)->default('')->comment('目的地详细地址');
            $table->string('dst_location',64)->default('')->comment('目的地经纬度');
            $table->integer('driving_distance')->default(0)->comment('驾车距离，单位：米');
            $table->integer('line_distance')->default(0)->comment('直线距离，单位：米');
            $table->integer('status')->default(1)->comment('路线状态，1可用；-1不可用');
            $table->timestamps();
            $table->index('owner_uuid', 'idx_owner_uuid');
            $table->index('status', 'idx_status');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('v_owner_routes');
    }
}
